﻿#include<iostream>
using namespace std;

union USER {
	short sHP;
	int nHP;
	double fHP;
};

int main() {
	USER user;
	cout << sizeof(user) << endl;//8

	user.nHP = 0;
	user.sHP = -1;//[0xFF][0xFF][0][0][][][][]

	cout << user.sHP << endl;//-1，正常赋值

	cout << user.nHP << endl;//65535，此时int的内存区域为0xFFFF0000，由于小端模式，读取内存变成0x0000FFFF，0x0000FFFF的值就是65535

}